package game.screen;

import game.Constants;
import game.Conversation;
import game.Person;
import game.manager.ConversationManager;
import game.manager.PersonManager;
import game.manager.ScreenManager;
import game.screen.option.BackOption;
import game.screen.option.ForwardOption;
import game.screen.option.ScreenOption;
import game.util.Util;

import java.util.List;
import java.util.Vector;

public class ProfileScreen extends Screen {
	private String header;
	private String body;
	private Person person;

	public ProfileScreen(String header, String body, Person person) {
		this.header = header;
		this.body = body;
		this.person = person;
	}

	@Override
	protected List<ScreenOption> getOptions() {
		Vector<ScreenOption> options = new Vector<ScreenOption>();
		options.add(new ScreenOption(Constants.SEND_MESSAGE) {

			@Override
			public void select() {
				final Person user = PersonManager.getManager().getUser();
				final Conversation conversation = ConversationManager
						.getManager().getConversation(user, person);
				ScreenManager.getManager().activateScreen(
						new ConversationScreen(conversation));
			}
		});
		options.add(new BackOption());
		options.add(new ForwardOption());
		return options;
	}

	public String getOptionTitle() {
		return this.person.getFullName() + " - " + this.getTitle();
	}

	@Override
	public String getTitle() {
		return this.header;
	}

	@Override
	public void print() {
		if (!this.printed) {
			this.printed = true;
			// Print the person's name
			printName();
			// Print the title
			printTitle();
			// Print the body
			printBody();
			// Print the options
			printOptions();
			// Let the user choose an option
			promptInput();
		}
	}

	private void printBody() {
		Util.print(this.body + "\n");
		printDivider();
	}

	private void printName() {
		Util.print(this.person.getFullName() + "\n");
	}

	@Override
	public void draw() {
	}
}
